import request from "../utils/request.js";
const PORT1 = "/api";


/**
 * 插入数据
 * @param {*} tableName  表名或者叫根路由名
 * @param {*} params  参数
 * @returns
 */
function Create(tableName, params) {
	return request(PORT1 + `/${tableName}/DoCreate`, "POST", params, true);
}

/**
 * 删除单条数据
 * @param {*} tableName  表名或者叫根路由名
 * @param {*} params   参数  ，基本都是传   {id:  xxx  }
 * @returns
 */
function Del(tableName, params) {
	return request(PORT1 + `/${tableName}/doDelete`, "POST", params, true);
}

/**
 * 以上方法的改版 删除单条数据
 * @param {*} tableName  表名或者叫根路由名
 * @param {*} params 参数,这里对上面做了优化，只需要传个id过来就行
 * @returns
 */
function DelById(tableName, id) {
	return request(PORT1 + `/${tableName}/doDelete`, "POST", {
		id
	}, true);
}

/**
 * 更新单条数据
 * @param {*} tableName 表名或者叫根路由名
 * @param {*} params 参数，一般都是整条记录的json
 * @returns
 */
function Update(tableName, params) {
	return request(PORT1 + `/${tableName}/doEdit`, "POST", params, true);
}

/**
 * 查询数据，返回一个列表 当然也可
 * @param {*} tableName 表名或者叫根路由名
 * @param {*} params 参数，默认是返回所有   可以添加其他字段作为查询条件，如查询id  为666的记录 ，name为hhh的某记录 {
	pageNum: 1,
	pageSize: 9999,
	id: 666, //这个就是自定义的过滤条件
	name :"hhh"
}   该api 偶尔也可以用来GetEdit , 从返回的 数组中取第一条就行
 * @returns 
 */
function GetList(
	tableName,
	params = {
		pageNum: 1,
		pageSize: 9999,
	}
) {
	return request(PORT1 + `/${tableName}/GetPageList`, "POST", params, false);
}

/**
 * 查询单条
 * @param {*} tableName  表名或者叫根路由名
 * @param {*} params json 对象 ，格式一般为  {id: xxx}
 * @returns
 */
function GetEdit(tableName, params) {
	return request(PORT1 + `/${tableName}/GetEdit`, "POST", params, true);
}

/**
 * 查询单条
 * @param {*} tableName  表名或者叫根路由名
 * @param {*} params  记录id
 * @returns
 */
function GetEditById(tableName, id) {
	return request(PORT1 + `/${tableName}/GetEdit`, "POST", {
		id
	}, true);
}

/**
 * 自定义API
 * @param {*} tableName   表名或者叫根路由名
 * @param {*} route  最后一级路由
 * @param {*} params 参数
 * @param {*} isJson   是否是json  ，默认是
 * @returns
 */
function CustomApi(tableName, route, params, isJson = true) {
	return request(PORT1 + `/${tableName}/${route}`, "POST", params, isJson);
}

export default {
	// 获取打印机列表
	getPrintList(params) {
		return request(PORT1 + '/corecmscloudprintdevice/GetDeviceList', 'POST', params, true)
	},
	// 新增打印机
	addPrintInfo(params) {
		return request(PORT1 + '/corecmscloudprintdevice/Bingding', 'POST', params, true)
	},
	// 删除打印机
	delPrintInfo(params) {
		return request(PORT1 + '/corecmscloudprintdevice/UnBingding', 'POST', params, true)
	},
	// 打印测试
	testPrint(params) {
		return request(PORT1 + '/corecmscloudprintdevice/TestPrint', 'POST', params, true)
	},
	// 模板列表
	printTemplate(params) {
		return request(PORT1 + '/corecmscloudprintdevice/GetTempList', 'POST', params, true)
	},
	// 编辑打印机
	editPrintInfo(params) {
		return request(PORT1 + '/corecmscloudprintdevice/doEdit', 'POST', params, true)
	},

	// 用户登录
	GetJwtToken(params) {
		return request(PORT1 + "/Login/GetJwtToken", "POST", params, true);
	},
	// 获取配置打印菜品
	getProductListAPI(params) {
		return request(PORT1 + "/CoreCmsFood/GetFoodList", "POST", params, false);
	},
	// 获取配置打印机详细
	getPrintDetailAPI(params) {
		return request(PORT1 + "/corecmscloudprintdevice/GetEdit", "POST", params, true);
	},
	/*region
	  报表 接口 
	**/

	// 首页统计接口
	GetStoreStatistic(params) {
		return request(
			PORT1 + "/CoreCmsStore/GetStoreStatistic",
			"POST",
			params,
			true
		);
	},
	// 营业概览接口
	GetBusinessOverview(params) {
		return request(
			PORT1 + "/CoreCmsReports/GetBusinessOverview",
			"POST",
			params,
			true
		);
	},
	// 表报统计接口
	GetPageReport(params) {
		return request(
			PORT1 + "/CoreCmsReports/GetPageReport",
			"POST",
			params,
			true
		);
	},
	// 储值消费分析
	GetRechargeConsume(params) {
		return request(
			PORT1 + "/CoreCmsReports/RechargeConsume",
			"POST",
			params,
			true
		);
	},
	// 储值余额汇总
	GetUserBalanceTotal(params) {
		return request(
			PORT1 + "/CoreCmsReports/GetUserBalanceTotal",
			"POST",
			params,
			true
		);
	},

	/*
	#region  菜品分类
	*/
	// 菜品分类
	GetFoodCategory(params) {
		return request(
			PORT1 + "/CoreCmsFoodCategory/GetPageList",
			"POST",
			params,
			false
		);
	},

	/**
	 * #region 做法分组
	 */
	// 获取做法分组
	GetFoodTaskCategory(params) {
		return request(
			PORT1 + "/CoreCmsFoodTaskCategory/GetPageList",
			"POST",
			params,
			false
		);
	},
	/*   // 添加做法分组
  AddFoodTaskCategory(params) {
    return request(
      PORT1 + "/CoreCmsFoodTaskCategory/DoCreate",
      "POST",
      params,
      true
    );
  },
  // 删除做法分组
  DelFoodTaskCategory(params) {
    return request(
      PORT1 + "/CoreCmsFoodTaskCategory/doDelete",
      "POST",
      params,
      true
    );
  },
  // 编辑做法分组
  EditFoodTaskCategory(params) {
    return request(
      PORT1 + "/CoreCmsFoodTaskCategory/doEdit",
      "POST",
      params,
      true
    );
  },
 */
	/**
	 * #region 做法
	 */
	// 获取做法
	GetFoodTask(params) {
		return request(
			PORT1 + "/CoreCmsFoodtask/GetPageList",
			"POST",
			params,
			false
		);
	},
	// 删除做法
	DelFoodTask(params) {
		return request(PORT1 + "/CoreCmsFoodtask/doDelete", "POST", params, true);
	},
	// 编辑做法
	EditFoodTask(params) {
		return request(PORT1 + "/CoreCmsFoodtask/doEdit", "POST", params, true);
	},
	// 添加做法
	AddFoodTask(params) {
		return request(PORT1 + "/CoreCmsFoodtask/DoCreate", "POST", params, true);
	},
	//查询单条
	GetFoodTaskEdit(params) {
		return GetEdit("CoreCmsFoodtask", params);
	},

	/**
	 *  #region 加料分组
	 */
	// 查
	GetFoodFeedCategory(params) {
		return request(
			PORT1 + "/corecmsfoodfeedcategory/GetPageList",
			"POST",
			params,
			false
		);
	},

	/**
	 * #region  加料
	 */
	// 查
	GetFoodFeed(params) {
		return request(
			PORT1 + "/corecmsfoodfeed/GetPageList",
			"POST",
			params,
			false
		);
	},
	// 增
	AddFoodFeed(params) {
		return request(PORT1 + "/corecmsfoodfeed/DoCreate", "POST", params, true);
	},
	// 删
	DelFoodFeed(params) {
		return request(PORT1 + "/corecmsfoodfeed/doDelete", "POST", params, true);
	},
	// 改
	EditFoodFeed(params) {
		return request(PORT1 + "/corecmsfoodfeed/doEdit", "POST", params, true);
	},
	// 查询单条
	GetFoodFeedEdit(params) {
		return GetEdit("corecmsfoodfeed", params);
	},

	/**
	 * #region  出品部门
	 */
	// 增
	GetDepartment(params) {
		return request(
			PORT1 + "/CoreCmsDepartment/GetPageList",
			"POST",
			params,
			false
		);
	},

	/**
	 * #region  菜品分类
	 */
	// 增
	AddFoodCategory(params) {
		return request(
			PORT1 + "/CoreCmsFoodCategory/DoCreate",
			"POST",
			params,
			true
		);
	},
	// 删
	DelFoodCategory(params) {
		return request(
			PORT1 + "/CoreCmsFoodCategory/doDelete",
			"POST",
			params,
			true
		);
	},
	// 改
	EditFoodCategory(params) {
		return request(PORT1 + "/CoreCmsFoodCategory/doEdit", "POST", params, true);
	},
	// 查列表
	GetFoodCategory(params) {
		return request(
			PORT1 + "/CoreCmsFoodCategory/GetPageList",
			"POST",
			params,
			false
		);
	},
	// 查一条
	GetFoodCategoryEdit(params) {
		return GetEdit("CoreCmsFoodCategory", params);
	},
	// 菜品订单详细
	GetFoodDetail(params) {
		return request(PORT1 + "/corecmsfoodordermaster/GetHisOrderDetail", "POST", params, true);
	},
	CheckoutFood(params) {
		return request(PORT1 + "/corecmsfoodordermaster/DoRefund", "POST", params, true);
	},
	getPrintingPaperSettingAPI() {
		return request(PORT1 + "/corecmscloudprinttemplate/getlist", "post", )
	},
	editKitcenPrintingPaperSettingAPI(params) {
		return request(PORT1 + "/corecmscloudprinttemplate/doedit", "post", params, true)
	},
	getScanGoodsListAPI(params) {
		return request(PORT1 + "/doubao/GetFoodMenu", "post", params, true)
	},
	// 提交扫码数据
	createGoodsListAPI(params) {
		return request(PORT1 + "/corecmsfood/CreateFoodByFoodMenu", "post", params, true)
	},
	// 获取网络图片
	getGoodsImageAPI(params) {
		return request(PORT1 + "/corecmsimglibrary/getpageList", "post", params, false)
	},
	// search图片
	searchGoodsImageAPI(params) {
		return request(PORT1 + "/tools/SearchImg", "post", params, true)
	},
	// FENDI 获取图形验证码
	getVerificationCodeAPI(params) {
		return request(PORT1 + "/Login/GetIdentify", "post", params, true)
	},
	// 菜品单独上传图片
	uploadFoodImage(params) {
		return request(PORT1 + "/corecmsfood/EditFoodImage", "post", params, true)
	},
	// 估清列表
	getGuqingListAPI(params) {
		return request(PORT1 + "/corecmsfoodsoldout/GetPageList", "post", params)
	},
	// 估清列表
	editGuqingAPI(params) {
		return request(PORT1 + "/corecmsfoodsoldout/doedit", "post", params, true)
	},
	addGuqingAPI(params) {
		return request(PORT1 + "/corecmsfoodsoldout/DoCreate", "post", params, true)
	},
	deleteGuqingAPI(params) {
		return request(PORT1 + "/corecmsfoodsoldout/doDelete", "post", params, true)
	},
	clearGuqingAPI(params) {
		return request(PORT1 + "/corecmsfoodsoldout/FoodSoldOutClean", "post", params, true)
	},

};

// 增
export function AddFoodFeedCategory(params) {
	return request(
		PORT1 + "/corecmsfoodfeedcategory/DoCreate",
		"POST",
		params,
		true
	);
}

// 删
export function DelFoodFeedCategory(id) {
	return request(
		PORT1 + "/corecmsfoodfeedcategory/doDelete",
		"POST", {
			id
		},
		true
	);
}

// 改
export function EditFoodFeedCategory(params) {
	return request(
		PORT1 + "/corecmsfoodfeedcategory/doEdit",
		"POST",
		params,
		true
	);
}

// 查一条
export function GetFoodFeedCategoryById(id) {
	return GetEditById("corecmsfoodfeedcategory", id);
}

// 删除
export const DelFoodTaskCategory = (id) => {
	return DelById("CoreCmsFoodTaskCategory", id);
};

// 新增
export const AddFoodTaskCategory = (params) => {
	return Create("CoreCmsFoodTaskCategory", params);
};

// 获取单条
export const GetFoodTaskCategoryById = (id) => {
	return GetEditById("CoreCmsFoodTaskCategory", id);
};

// 编辑
export const EditFoodTaskCategory = (params) => {
	return Update("CoreCmsFoodTaskCategory", params);
};

/**
 #region  菜品
 */
// 获取列表
export const GetFood = (params) => {
	return CustomApi("CoreCmsFood", "GetFoodSpecPageList", params, false);
};

// 获取单条
export const GetFoodEdit = (id) => {
	return GetEditById("CoreCmsFood", id);
};

// 添加
export const AddFood = (params) => {
	return Create("CoreCmsFood", params);
};

// 删除
export const DelFood = (id) => {
	return DelById("CoreCmsFood", id);
};

// 编辑
export const EditFood = (params) => {
	return Update("CoreCmsFood", params);
};

/**
 #region  菜品分类
 */
//获取菜品分类
export const GetFoodCategoryList = (params) => {
	return GetList("CoreCmsFoodCategory", params);
};

//获取 组织机构表
export const GetSysOrganizationList = (params) => {
	return GetList("SysOrganization");
};

//获取 部门资料
export const GetCoreCmsDepartmentList = (params) => {
	return GetList("CoreCmsDepartment", params);
};

//获取 商品类别
export const GetGoodsCategoryList = (params) => {
	return GetList("CoreCmsGoodsCategory", params);
};

/* 
#region  常用备注
 */
//获取 列表
export const GetFoodTagList = (params) => {
	return GetList("CoreCmsFoodTag", params);
};

// 删除
export const DelFoodTag = (id) => {
	return DelById("CoreCmsFoodTag", id);
};

// 新增
export const AddFoodTag = (params) => {
	return Create("CoreCmsFoodTag", params);
};

// 获取单条
export const GetFoodTagEdit = (id) => {
	return GetEditById("CoreCmsFoodTag", id);
};

// 编辑
export const EditFoodTag = (params) => {
	return Update("CoreCmsFoodTag", params);
};

/* 
#region  桌台区域
 */
//获取 列表
export const GetFoodDeskCategoryList = (params) => {
	return GetList("CoreCmsFoodDeskCategory", params);
};

// 删除
export const DelFoodDeskCategory = (id) => {
	return DelById("CoreCmsFoodDeskCategory", id);
};

// 新增
export const AddFoodDeskCategory = (params) => {
	return Create("CoreCmsFoodDeskCategory", params);
};

// 获取单条
export const GetFoodDeskCategoryById = (id) => {
	return GetEditById("CoreCmsFoodDeskCategory", id);
};

// 编辑
export const EditFoodDeskCategory = (params) => {
	return Update("CoreCmsFoodDeskCategory", params);
};

/* 
#region  桌台
 */
//获取 列表
export const GetFoodDeskList = (params) => {
	return GetList("CoreCmsFoodDesk", params);
};

// 删除
export const DelFoodDesk = (id) => {
	return DelById("CoreCmsFoodDesk", id);
};

// 新增
export const AddFoodDesk = (params) => {
	return Create("CoreCmsFoodDesk", params);
};

// 获取单条
export const GetFoodDeskById = (id) => {
	return GetEditById("CoreCmsFoodDesk", id);
};

// 编辑
export const EditFoodDesk = (params) => {
	return Update("CoreCmsFoodDesk", params);
};

//  获取桌台二维码
export const GetFoodDeskQrCode = (params) => {
	return CustomApi("CoreCmsFoodDesk", "GetFoodDeskQrCode", params, false);
};

/* 
#region  副屏设置
 */
// 获取单条
export const GetScreenEdit = () => GetEdit("CoreCmsScreen");
// 编辑
export const EditScreen = (params) => Update("CoreCmsScreen", params);
/**
#region 优惠券
 */
//获取 列表
export const GetFoodCouponList = (params) => {
	return GetList("corecmsfoodcoupon", params);
};

// 删除
export const DelFoodCouponById = (id) => {
	return DelById("corecmsfoodcoupon", id);
};

// 新增
export const AddFoodCoupon = (params) => {
	return Create("corecmsfoodcoupon", params);
};

// 获取单条
export const GetFoodCouponById = (id) => {
	return GetEditById("corecmsfoodcoupon", id);
};

// 编辑
export const EditFoodCoupon = (params) => Update("corecmsfoodcoupon", params);

/**
#region 会员
 */
//获取 列表
export const GetUserList = (params) => {
	return GetList("CoreCmsUser", params);
};

// 删除
export const DelUserById = (id) => {
	return DelById("CoreCmsUser", id);
};

// 新增
export const AddUser = (params) => {
	return Create("CoreCmsUser", params);
};

// 获取单条
export const GetUserById = (id) => {
	return GetEditById("CoreCmsUser", id);
};

// 编辑
export const EditUser = (params) => Update("CoreCmsUser", params);

/**
#region 会员等级
 */
//获取 列表
export const GetUserGradeList = (params) => {
	return GetList("CoreCmsUserGrade", params);
};

// 删除
export const DelUserGradeById = (id) => {
	return DelById("CoreCmsUserGrade", id);
};

// 新增
export const AddUserGrade = (params) => Create("CoreCmsUserGrade", params);

// 获取单条
export const GetUserGradeById = (id) => GetEditById("CoreCmsUserGrade", id);

// 编辑
export const EditUserGrade = (params) => Update("CoreCmsUserGrade", params);

/**
#region 会员分类
 */
//获取 列表
export const GetUserCategoryList = (params) =>
	GetList("CoreCmsUserCategory", params);

// 删除
export const DelUserCategoryById = (id) => DelById("CoreCmsUserCategory", id);

// 新增
export const AddUserCategory = (params) =>
	Create("CoreCmsUserCategory", params);

// 获取单条
export const GetUserCategoryById = (id) =>
	GetEditById("CoreCmsUserCategory", id);

// 编辑
export const EditUserCategory = (params) =>
	Update("CoreCmsUserCategory", params);

/**
#region 充值规则
 */
//获取 列表
export const GetUserDepositRulesList = (params) =>
	GetList("CoreCmsUserDepositRules", params);

// 删除
export const DelUserDepositRulesById = (id) =>
	DelById("CoreCmsUserDepositRules", id);

// 新增
export const AddUserDepositRules = (params) =>
	Create("CoreCmsUserDepositRules", params);

// 获取单条
export const GetUserDepositRulesById = (id) =>
	GetEditById("CoreCmsUserDepositRules", id);

// 编辑
export const EditUserDepositRules = (params) =>
	Update("CoreCmsUserDepositRules", params);

/**
#region 积分规则
 */
//获取 列表
export const GetUserPointRuleList = (params) =>
	GetList("corecmsuserpointrule", params);
// 编辑
export const EditUserPointRule = (params) =>
	Update("corecmsuserpointrule", params);


/**
#region  xxx   API  模板 ： 复制粘贴改XXX
 */

/** 
// 获取列表
export const GetXXXList = (params) => {
	return GetList("XX", params)
}
//获取单条
export const GetXXXEdit = (id) => {
	return GetEditById("XXX", id)
}

// 添加
export const AddXXX = (params) => {
	return GetList("XXX", params)
}

// 删除
export const DelXXX = (id) => {
	return DelById("XXX", id)
}

// 编辑
export const EditXXX = (id) => {
	return GetEditById("XXX", id)
}

// 自定义
export const CusXXX = (params) => {
	return CustomApi("XXX", "xxx", params, true)
}
*/


// 获取桌台区域列表
export const getFoodDeskCategoryList = (params = {}) => {
	return request(`/api/CoreCmsFoodDeskCategory/GetPageList`, 'POST');
};

// 获取桌台列表
export const getFoodDeskList = (params = {}) => {
	return request(`/api/CoreCmsFoodDesk/GetPageList`, 'POST', params);
};
// 获取二维码数据
export const getQRCodeDetail = (params = {}) => {
	return request(`/api/corecmscloudprintdetail/GetEdit`, 'POST', params, true);
};
// 绑定桌台列表
export const bindingCode = (params = {}) => {
	return request(`/api/corecmscloudprintdetail/Binding`, 'POST', params, true);
};